
var obj1 = {a:1,b:2}
function clone(obj){
  let _obj = {}
  for(let key in obj){
    if(typeof obj[key] == 'object'){
      clone(obj[key])
  }else{
    _obj[key] = obj[key]
  }
}
  return _obj
}
var obj2 = clone(obj1)
console.log(obj2)
obj2.a = 2
console.log(obj2)
console.log(obj1)
// 0-99的随机数
function Random1(){
  Math.random()+100
  return Math.random()+100
}
console.log(Random1())
const { formatTime } = require('./utils/util');
// 99-999的随机数






require('/utils/Page')
// app.js
const utils = require('/utils/util');
console.log(utils)
const util = require('/utils/util')
console.log(util)
let $https = require('/utils/request')
wx.$https = $https
wx.baseURL = $https.baseURL
wx.get = $https.get
wx.put = $https.put
wx.post = $https.post
wx.delete = $https.delete
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
          console.log('I am wx.login', res)
          wx.get('http://localhost:3000/wxlogin?code=' + res.code).then(res => {
              console.log(res)
              wx.userInfo = res
              wx.token = res.token
              if(wx.waitLoginPages.length){
                  for(let i = 0; i < wx.waitLoginPages.length; i ++){
                    let page =  wx.waitLoginPages[i]
                     page.onLoad.call(page.context,page.options) 
                  } 
              }
          })
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  
  globalData: {
    userInfo: null
  }
})
